﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
	xmlns:ui="clr-namespace:DMC.UI"
	mc:Ignorable="d"
	x:Class="DMC.UI.ProgressWheelWedge"
	x:Name="UserControl"
	Width="Auto" 
    Height="Auto">

    <UserControl.Resources>
        <ui:ProgressWheelWedge x:Key="Dummy" Color="#95221F" />
    </UserControl.Resources>
    
    <Grid DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ui:ProgressWheelWedge}}"
          d:DataContext="{Binding Source={StaticResource Dummy}}">
        
		<Canvas Width="200" Height="200">
            <Path Fill="{Binding Path=Color}">
                <Path.Data>
                    <PathGeometry>
                        <PathFigure StartPoint="{Binding Path=Point1}" IsClosed="True">
                            <ArcSegment Point="{Binding Path=Point2}" Size="100,100" SweepDirection="Clockwise" />
                            <LineSegment Point="{Binding Path=Point3}" />
                            <ArcSegment Point="{Binding Path=Point4}" Size="50,50" SweepDirection="Counterclockwise" />
                        </PathFigure>
                    </PathGeometry>
                </Path.Data>
                <Path.RenderTransform>
                    <TransformGroup>
                        <RotateTransform CenterX="100" CenterY="100" Angle="{Binding Path=Angle}" />
                    </TransformGroup>
                </Path.RenderTransform>
                <Path.Triggers>
                    <EventTrigger RoutedEvent="Loaded">
                        <BeginStoryboard>
                            <Storyboard RepeatBehavior="Forever" 
                                        BeginTime="{Binding Path=BeginTime}">
                                <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                 From="1.0" 
                                                 To="0.0" 
                                                 BeginTime="0:0:0"
                                                 Duration="0:0:0.25" />
                                <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                 From="0.0" 
                                                 To="1.0" 
                                                 BeginTime="0:0:0.25"
                                                 Duration="0:0:0.25" />
                                <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                 From="1.0" 
                                                 To="1.0" 
                                                 BeginTime="0:0:0.5"
                                                 Duration="0:0:0.5" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Path.Triggers>
            </Path>
            <!--
            <Polygon Fill="{Binding Path=Color}">
            	<Polygon.Points>
            		<Point X="75" Y="0" />
                    <Point X="125" Y="0" />
                    <Point X="105" Y="50" />
                    <Point X="95" Y="50" />        	
				</Polygon.Points>
                <Polygon.RenderTransform>
                    <TransformGroup>
                        <RotateTransform CenterX="100" CenterY="100" Angle="{Binding Path=Angle}" />
                    </TransformGroup>
                </Polygon.RenderTransform>
                <Polygon.Triggers>
                    <EventTrigger RoutedEvent="Loaded">
                        <BeginStoryboard>
                            <Storyboard RepeatBehavior="Forever" 
                                        BeginTime="{Binding Path=BeginTime}">
                                <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                 From="1.0" 
                                                 To="0.0" 
                                                 BeginTime="0:0:0"
                                                 Duration="0:0:0.25" />
                                <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                 From="0.0" 
                                                 To="1.0" 
                                                 BeginTime="0:0:0.25"
                                                 Duration="0:0:0.25" />
                                <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                 From="1.0" 
                                                 To="1.0" 
                                                 BeginTime="0:0:0.5"
                                                 Duration="0:0:0.5" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Polygon.Triggers>
            </Polygon>
            -->
		</Canvas>
        
	</Grid>
</UserControl>